package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.entity.Result;
import com.itheima.pojo.CheckItem;
import com.itheima.service.CheckItemService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/checkItem")
public class CheckItemController {

    @Reference
    private CheckItemService checkItemService;

    @RequestMapping("/add")
    public Result add(@RequestBody CheckItem checkItem){
       return checkItemService.add(checkItem);
    }

    @RequestMapping("/selectAllByName")
    public PageResult selectAllByName(@RequestBody QueryPageBean queryPageBean){
       return checkItemService.selectAllByName(queryPageBean);
    }

    @RequestMapping("/deleteById")
    @PreAuthorize("hasAuthority('CHECKITEM_DELETE')")
    public Result deleteById(int id){
       return checkItemService.deleteById(id);
    }

    @RequestMapping("/updateOne")
    public Result updateOne(@RequestBody CheckItem checkItem){
      return checkItemService.updateOen(checkItem);
    }

    @RequestMapping("/findAll")
    public List<CheckItem> findAll(){
       return checkItemService.findAll();
    }
}
